Skip to content

Apply entity styles when rendering to a SolidModel - #369

Merged
gpeairs merged 2 commits into
mainfrom
gp/solidmodel-styles
Nov 10, 2026
Merged

gpeairs merged 2 commits into
mainfrom
gp/solidmodel-styles

Conversation

@gpeairs

@gpeairs gpeairs commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Rendering a StyledEntity to a SolidModel silently dropped any style that didn't have its own SolidModel method. For example, Rounded didn't round on the GmshNative kernel, StyleDict(Rounded(…)) on a plain polygon didn't round on either kernel, and a custom style implemented through to_polygons rendered in a Cell but was ignored in a SolidModel. Separately, Rounded on an ellipse or circle on OpenCascade recursed until the stack overflowed, and so did to_polygons with a StyleDict on a single polygon such as a Rectangle.

Now:

  • Styles without a SolidModel method are applied through to_polygons, as in Cell rendering. On OpenCascade this discretizes curves, so it warns once per type.
  • Plain, MeshSized and WithDirection still pass through, so native curves survive.
  • ToTolerance renders its entity with its atol.
  • Rounded ellipses and circles on OpenCascade stay exact, since they have no corners.
  • StyleDict on an entity other than a ClippedPolygon or CurvilinearRegion, such as a Rectangle or a path node, applies its style at [1] to the whole entity, in 2D and in SolidModels. Styles at other indices throw an ArgumentError, since there are no contours for them to apply to.
  • The SolidModel concepts page describes how styles are applied, and the GeometryEntityStyle docstring says how to keep curves for a custom style on OpenCascade.

Tests cover each case on both kernels, nested styles, and a full render!.

to_primitives(::SolidModel, ::StyledEntity) rendered the unstyled entity, so
any style without a SolidModel method of its own was silently dropped:
Rounded on GmshNative, StyleDict on a single polygon, and user-defined
styles. Apply such styles through to_polygons, as rendering to a Cell does,
warning once per type on OpenCascade when that discretizes curves. Plain,
MeshSized and WithDirection still pass through, keeping native curves, and
ToTolerance renders its entity with its atol.

Rounded on OpenCascade re-wrapped an ellipse in the style and recursed until
the stack overflowed; ellipses now come back exact. StyleDict on an entity
without a contour tree, such as a Rectangle or path node, applies its style
at [1] in 2D and in SolidModels, instead of recursing, and throws an
ArgumentError for styles at other indices.

The GeometryEntityStyle docstring says how to keep curves for a custom style
on OpenCascade.
@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@gpeairs
gpeairs requested a review from laylagi November 6, 2026 15:09

@laylagi laylagi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@gpeairs
gpeairs merged commit c441c13 into main Nov 10, 2026
11 checks passed
@gpeairs
gpeairs deleted the gp/solidmodel-styles branch November 10, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants